using System;
using System.Collections.Generic;
using Castle.ActiveRecord;

namespace GettingStartedSample.Models
{
    [ActiveRecord]
    public class Activity : ActiveRecordBase
    {
        [PrimaryKey]
        public Int64 Id { get; set; }

        [Property]
        public string Name { get; set; }

        public static Activity FindById(Int64 id)
        {
            return (Activity) FindByPrimaryKey(typeof (Activity), id);
        }

        public static List<Activity> FindAll()
        {
            return new List<Activity>((IEnumerable<Activity>) FindAll(typeof (Activity)));
        }

        public static Activity FindByName(string activity)
        {
            Array activities = FindAllByProperty(typeof (Activity), "Name", activity);
            return new List<Activity>((IEnumerable<Activity>) activities)[0];
        }
    }
}